﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace _0517病例系统
{
    public partial class frmCharge : Form
    {
        public frmCharge()
        {
            InitializeComponent();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void button1_Click(object sender, EventArgs e)
        {
           
        }

        private void label8_Click(object sender, EventArgs e)
        {
            
        }

        private void frmCharge_Load(object sender, EventArgs e)
        {
            label2.Text = _0517病例系统.frmfindcs.z;
            label4.Text = _0517病例系统.frmfindcs.s;
            label6.Text = _0517病例系统.frmfindcs.l;
            label8.Text = _0517病例系统.frmfindcs.k;
            label14.Text = _0517病例系统.frmfindcs.v;
            label17.Text = _0517病例系统.frmfindcs.q;
            label20.Text = _0517病例系统.frmfindcs.h;
            textBox1.Text = _0517病例系统.frmfindcs.r;
            textBox2.Text = _0517病例系统.frmfindcs.w;
            textBox3.Text = _0517病例系统.frmfindcs.f;
            this.timer1.Interval = 1000;
            this.timer1.Start();
        }

        private void button2_Click_1(object sender, EventArgs e)
        {
            this.Hide();
        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            this.Close();
            _0517病例系统.frmfindcs ff = new _0517病例系统.frmfindcs();
            ff.Show();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            textBox4.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex == 0)
            {
                decimal b = (numericUpDown1.Value) * 15;
                label14.Text = b.ToString();
                label24.Text = (Convert.ToInt32(label14.Text) + Convert.ToInt32(label17.Text) + Convert.ToInt32(label20.Text)).ToString();
            }
            if (comboBox1.SelectedIndex == 1)
            {
                decimal b = (numericUpDown1.Value) * 15;
                label14.Text = b.ToString();
                label24.Text = b.ToString();
                label24.Text = ((Convert.ToInt32(label14.Text) + Convert.ToInt32(label17.Text) + Convert.ToInt32(label20.Text))*0.3).ToString();
            }
            if (comboBox1.SelectedIndex == 2)
            {
                decimal b = (numericUpDown1.Value) * 15;
                label14.Text = b.ToString();
                label24.Text = b.ToString();
                label24.Text = ((Convert.ToInt32(label14.Text) + Convert.ToInt32(label17.Text) + Convert.ToInt32(label20.Text)) * 0.2).ToString();
            }
        }

        private void label14_Click(object sender, EventArgs e)
        {  
        }

        private void numericUpDown1_ValueChanged(object sender, EventArgs e)
        {
            decimal b = (numericUpDown1.Value) * 15;
            label14.Text = b.ToString(); ;
            label29.Text = (Convert.ToInt32(label14.Text) + Convert.ToInt32(label17.Text) + Convert.ToInt32(label20.Text)).ToString();

        }

        private void button3_Click(object sender, EventArgs e)
        {
            string strSql;
            DataAccess data = new DataAccess();
            strSql = "insert into Shoufeiss(编号,姓名,年龄,电话,药品项目,药品单价,项目检查,检查单价,检验项目,检验单价,报销方式,收入时间,应缴总金额,药品数量) values('" + label2.Text + "','" + label4.Text + "','" + label6.Text + "','" + label8.Text + "','" + textBox1.Text + "','" + label14.Text + "','" + textBox2.Text + "','" + label17.Text + "','" + textBox3.Text + "','" + label20.Text + "','" + comboBox1.Text + "','" + textBox4.Text + "','" + label24.Text + "','" + numericUpDown1.Value + "')";
            data.dataCon();
            if (data.sqlExec(strSql))
            {
                MessageBox.Show("已成功添加到数据库！");

            }
            else
            {
                MessageBox.Show("添加失败！");
            }
            this.Hide();
        }
    }
}
